/**
 * Created by yongwang on 2015/9/16.
 */

var integralStrategyService = require('../../../services/mis/master/integralStrategyService');
var messageUtil = require('../../../common/utils/messageUtil');
var toolUtil = require('../../../common/utils/toolUtil');

exports.integralStrategyList = function(req, res) {

    integralStrategyService.integralStrategyServiceList(req, function (err, results) {
        logger.debug('questionStoreLis');
        if (err) {
            logger.error('Exception happen when questionStoreList...' + err.message);
            res.json(messageUtil.composeFailedMessage(req, 'Exception happen when questionStoreList...'));
        } else {
            var data={};
            var data = {
                count: results[0]["count"],
                totalPage: results[0]["totalPage"],
                list: results[1]
            };
            //logger.debug('data: ');
            //logger.debug(data);
            res.json(messageUtil.composeSucceededMessage(req, null, data));

        }

    });
};

exports.integralStrategyAdd = function(req, res){
    integralStrategyService.integralStrategyAddService(req, function(err, results) {

        if (err) {
            res.json(messageUtil.composeFailedMessage(req, 'Exception happen when integralStrategyAdd...'));
        }else {
            res.json(messageUtil.composeSucceededMessage(req, null, results));
        }
    });
};

exports.integralStrategyDelete = function(req, res){
    integralStrategyService.integralStrategyDeleteService(req, function(err, results) {

        if (err) {
            res.json(messageUtil.composeFailedMessage(req, 'Exception happen when integralStrategyDelete...'));
        }else {
            res.json(messageUtil.composeSucceededMessage(req, null, results));
        }
    });
};

exports.integralStrategyEdit = function(req, res){
    integralStrategyService.integralStrategyEditService(req, function(err, results) {

        if (err) {
            res.json(messageUtil.composeFailedMessage(req, 'Exception happen when integralStrategyEdit...'));
        }else {
            res.json(messageUtil.composeSucceededMessage(req, null, results));
        }
    });
};